<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Model\OperationLogs;
use App\Model\RedPacketRain;

class RedPacketRainController extends BaseController
{
    protected $model = null;

    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->model = new RedPacketRain();
    }

    //红包雨新增
    public function redPacketRainAdd(Request $request){
        $res = $this->model->redPacketRainAdd($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '红包雨新增');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //红包雨编辑
    public function redPacketRainEdit(Request $request){
        $res = $this->model->redPacketRainEdit($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '红包雨编辑');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //红包雨删除
    public function redPacketRainDel(Request $request){
        $res = $this->model->redPacketRainDel($request->all(), $this->user);
        if($res['code'] == self::SUCCESS) {
            OperationLogs::createData($request, OperationLogs::ACTIVITY, '红包雨删除');
        }
        return $this->toJson($res['code'], $res['data'], $res['msg']);
    }

    //红包雨列表
    public function redPacketRainList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->redPacketRainList($request));
    }

    //红包雨记录列表
    public function redPacketRainLogList(Request $request){
        return $this->toJson(self::SUCCESS, $this->model->redPacketRainLogList($request));
    }

}
